<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
	<meta charset="utf-8">
	<title>生产制造部待办生产异常</title>
	<meta name="renderer" content="webkit">
	<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
	<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/layui.css"  media="all">
	<link rel="stylesheet" href="${pageContext.request.contextPath }/assets/css/toastr.min.css"  media="all">
</head>
<body>
<div class="layui-tab layui-tab-card">
	<ul class="layui-tab-title">
		<li class="layui-this">工艺通知单待办</li>
		<li>生产异常待办</li>
	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show">
			<div class="demoTable" style="padding:10px 0 0 15px">
				<div class="layui-inline">
					<input class="layui-input" name="keyword1" id="keyword1" autocomplete="off" placeholder="请输入工艺通知单编号">
				</div>
				<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
			</div>
			<table class="layui-hide" id="test1" lay-filter="test1"></table>
		</div>
		<div class="layui-tab-item">
			<div class="demoTable" style="padding:10px 0 0 15px">
				<div class="layui-inline">
					<input class="layui-input" name="keyword2" id="keyword2" autocomplete="off" placeholder="请输入生产异常处置单编号">
				</div>
				<button class="layui-btn layui-btn-blue" style="margin: 0 0 0 10px" data-type="reload"><i class="layui-icon layui-icon-search">  搜索</i></button>
			</div>
			<table class="layui-hide" id="test" lay-filter="test"></table>
		</div>
	</div>
</div>
<div class="layui-tab" id="tab" style="width: 90%;padding: 2em 0 0 5em;display: none;">
	<ul class="layui-tab-title">
		<li class="layui-this">工艺处理结果</li>
		<li>品质处理结果</li>
	</ul>
	<div class="layui-tab-content">
		<div class="layui-tab-item layui-show" id="tab1"></div>
		<div class="layui-tab-item" id="tab2"></div>
	</div>
</div>
<div id="formDiv" style="display: none;" align="center">
</div>
<div id="formDiv2" hidden>
	<form class="layui-form">
		<h1 align="center">工艺变更通知单</h1><br>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">编号</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="noticeNum" name="noticeNum" style="width:300px;">
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">日期</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="noticeDate" name="noticeDate" style="width:300px;">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">有效期</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="validityPeriod" name="validityPeriod" style="width:300px;">
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">适用工序</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="applicableProcess" name="applicableProcess" style="width:300px;">
				</div>
			</div>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">内容</label>
				<div class="layui-input-inline">
					<textarea class="layui-textarea" readonly id="content" name="content" style="width:300px;"></textarea>
				</div>
			</div>
			<div class="layui-inline" style="padding-left: 5em;">
				<label class="layui-form-label" style="width: 100px;">拟定人</label>
				<div class="layui-input-inline">
					<input class="layui-input" readonly type="text" id="draftPerson" name="draftPerson" style="width:300px;">
				</div>
			</div>
		</div>
	</form>
</div>
<div id="formDiv3" hidden>
	<form class="layui-form" id="addform">
		<input type="hidden" id="adID" name="adID"><input type="hidden" id="reserve1" name="reserve1" value="1"><input type="hidden" id="reserve2" name="reserve2"><br>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">意见</label>
				<div class="layui-input-inline">
					<textarea class="layui-textarea" id="opinion3" name="opinion3" style="width:300px;"></textarea>
				</div>
			</div><span style="color:red; font-size: 24px;float: right;margin: 35px 2em 0 0;">*</span>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">是否通过</label>
				<div class="layui-input-inline">
					<input type="radio" name="reserve5" value="0" title="通过" checked><input type="radio" name="reserve5" value="1" title="驳回">
				</div>
			</div>
		</div>
		<button id="subBtn1" class="layui-btn layui-btn-blue" lay-submit lay-filter="addform" style="margin-left:140px">提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</form>
</div>
<div id="formDiv4" hidden>
	<form class="layui-form" id="addform2">
		<input type="hidden" id="reserve5" name="reserve5" value="4">
		<input type="hidden" id="noticeID" name="noticeID"><br>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">会签意见</label>
				<div class="layui-input-inline">
					<textarea lay-verify="reserve4" class="layui-textarea" id="reserve4" name="reserve4" style="width:300px;"></textarea>
				</div>
			</div><span style="color:red; font-size: 24px;float: right;margin: 35px 2em 0 0;">*</span>
		</div>
		<div class="layui-form-item">
			<div class="layui-inline">
				<label class="layui-form-label" style="width: 100px;">是否通过</label>
				<div class="layui-input-inline">
					<input type="radio" name="type" value="0" title="通过" checked><input type="radio" name="type" value="1" title="驳回">
				</div>
			</div>
		</div>
		<button id="subBtn2" class="layui-btn layui-btn-blue" lay-submit lay-filter="addform2" style="margin-left:140px">提交</button>&emsp;&emsp;&emsp;&emsp;<button type="reset" class="layui-btn layui-btn-primary">重置</button>
	</form>
</div>

<script type="text/html" id="toolbarDemo">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" lay-event="add"><i class="layui-icon layui-icon-edit">  签字</i></button>
	</div>
</script>
<script type="text/html" id="toolbarDemo1">
	<div class="layui-btn-container">
		<button class="layui-btn layui-btn-blue" lay-event="add1"><i class="layui-icon layui-icon-add-1">  会签</i></button>
	</div>
</script>
              
          
<script src="${pageContext.request.contextPath }/assets/layui.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/layui.all.js"></script>
<script src="${pageContext.request.contextPath }/assets/js/jquery.min.js" charset="utf-8"></script>
<script src="${pageContext.request.contextPath }/assets/js/toastr.min.js" charset="utf-8"></script>
<jsp:include page="ScriptInc.jsp"></jsp:include> 
 
<script>
layui.use(['table','layer','upload','form'], function(){
	
	var table = layui.table;
	var layer = layui.layer,
    form = layui.form;
	var $ = layui.jquery, active = {
			reload:function () {
				var keyword1 = $("#keyword1").val();
				var keyword2 = $("#keyword2").val();
				table.reload('contenttable1',{
					method:'get',
					where:{noticeNum: keyword1,
						reserve1: '3',
						reserve5: '3'}
					,page: {
						curr: 1 //重新从第 1 页开始
					}
				});
				table.reload('contenttable',{
					method:'get',
					where:{adNum: keyword2,
						reserve1: '3'}
					,page: {
						curr: 1 //重新从第 1 页开始
					}
				});
			}
		}
	
	$('.layui-btn').on('click', function(){
        var type = $(this).data('type');
        active[type] ? active[type].call(this) : '';
    });
	table.render({
	    elem: '#test'
	    ,url:'${pageContext.request.contextPath }/abnormalDisposal/listPageAbnormalDisposal.do'
	    ,toolbar: '#toolbarDemo'
	    ,title: '生产异常处置单数据表'
	    ,id :'contenttable'
	    ,limits:[10,20,30]
	    ,where:{reserve1: '3'}
	    ,cols: [[
	      {type: 'checkbox', fixed: 'left'}
	      ,{type: 'numbers', fixed: 'left', title:'序号', width:'5%'}
	      ,{field:'adNum', title:'编号', width:'10%'}
	      ,{field:'processPart', title:'发生的工序段', width:'10%'}
	      ,{field:'adDate', title:'日期', width:'10%', templet: function(d){
	          return timestampToDate(d.adDate.time);
	      }}
	      ,{field:'squadLeader', title:'当班班长', width:'10%'}
	      /* ,{field:'processer', title:'工艺段负责', width:'10%'} */
	      ,{field:'description', title:'异常说明'}
	    ]]
	    ,page: true
	});
	table.render({
		elem: '#test1'
	    ,url:'${pageContext.request.contextPath }/changeNotice/listPageChangeNotice.do'
	    ,toolbar: '#toolbarDemo1'
	    ,title: '工艺通知单数据表'
	    ,id :'contenttable1'
	    ,limits:[10,20,30]
	    ,where:{reserve1: '3',reserve5: '3'}
	    ,cols: [[
	      {type: 'checkbox', fixed: 'left'}
	      ,{type: 'numbers', title:'序号', fixed: 'left', width:'5%', unresize: true, sort: true}
	      ,{field:'noticeNum', title:'编号'}
	      ,{field:'draftDepartment', title:'制定部门'}
	      ,{field:'noticeDate', title:'制定日期', templet: function(d){
	          return timestampToDate(d.noticeDate.time);
	      }}
	      ,{field:'validityPeriod', title:'有效期'}
	      ,{field:'applicableProcess', title:'适用工序'}
	      ,{field:'content', title:'内容'}
	      ,{field:'draftPerson', title:'拟定人'}
	      ,{field:'approvalRecord', title:'处理记录', templet: function(d){
	    	  return "<a href='javascript:void(0)' style='color:#4D61B3' onclick='attachDeviceEvent(\""+
	    			  d.reserve5+"\",\""+d.reserve2+"\",\""+d.qSignature+"\",\""+d.reserve3+"\",\""+
	    			  d.tSignature+"\",\""+d.reserve4+"\",\""+d.maSignature+"\",\""+d.mOpinion+
	    			  "\",\""+d.mSignature+"\")'>"+'查看详细'+"</a>";
	      }}
	    ]]
	    ,page: true
	});
	
	//监听行单击事件
	table.on('row(test)', function(obj){
		$.ajax({
	    	type:'post',
	    	url:'${pageContext.request.contextPath }/abnormalDisposalCraft/findAbnormalDisposalCraftByAdID.do',
	    	data:{"adID": obj.data.adID},
	    	success:function(data){
	    		$('#tab1').empty();
	    		var abnormalDisposalCraft = eval("("+data+")");
	    		if (abnormalDisposalCraft[0] == null) {
	    			$('#tab1').append('<div style="text-align: center;font-size: 25px;font-weight: 500;padding-top: 1em;">未处理</div>');
				} else {
					var isNormal = '';
					var reserve1 = '';
		    		if (abnormalDisposalCraft[0].reserve1 == '0') {
		    			reserve1 = '(已通过)';
		    		} else {
		    			reserve1 = '(已驳回)';
					}
		    		if (abnormalDisposalCraft[0].isNormal == '0') {
		    			isNormal = '未恢复正常';
		    			$('#tab1').append('<h1 style="text-align: center;">工艺处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
			    				'<tbody><tr height="100px;"><td style="width: 10%;">调整过程描述</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionDescription+'</td><td style="width: 10%;">调整结果说明</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionResult+'</td><td style="width: 10%;">'+isNormal+'</td></tr><tr><td colspan="5" '+
			    				'style="text-align: right;">负责人:'+abnormalDisposalCraft[0].craftMan+reserve1+'</td></tr></tbody></table>');
					} else {
						isNormal = '已恢复正常';
						$('#tab1').append('<h1 style="text-align: center;">工艺处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
			    				'<tbody><tr height="100px;"><td style="width: 10%;">调整过程描述</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionDescription+'</td><td style="width: 10%;">调整结果说明</td><td style="width: 30%;">'+
			    				abnormalDisposalCraft[0].revisionResult+'</td><td style="width: 10%;">'+isNormal+'</td><td style="width: 10%;">'+
			    				'<a class="layui-btn layui-btn-sm" id="view"><i class="layui-icon layui-icon-search">变更通知单</i></a></td></tr>'+
			    				'<tr><td colspan="6" style="text-align: right;">负责人:'+abnormalDisposalCraft[0].craftMan+reserve1+'</td></tr></tbody></table>');
					}
		    		$('#view').on('click', function() {
						layer.open({
							type: 1 		//Page层类型
							,area: ['60%', '50%'] //宽  高
							,title: '工艺变更通知单'
							,shade: 0.6 	//遮罩透明度
							,shadeClose: true //点击遮罩关闭
							,maxmin: true //允许全屏最小化
							,anim: 1 		//0-6的动画形式，-1不开启
							,content: $('#formDiv2')
							,success: function () {
								$.ajax({
					    			type:'post',
					    			url:'${pageContext.request.contextPath }/changeNotice/findChangeNoticeByID.do',
					    			data:{"noticeID": abnormalDisposalCraft[0].noticeID},
					    			success:function(data){
					    				var changeNotice = eval("("+data+")");
					    	    		$('#noticeNum').val(changeNotice[0].noticeNum);
					    	    		$('#noticeDate').val(timestampToDate(changeNotice[0].noticeDate.time));
					    	    		$('#validityPeriod').val(changeNotice[0].validityPeriod);
					    	    		$('#applicableProcess').val(changeNotice[0].applicableProcess);
					    	    		$('#content').val(changeNotice[0].content);
					    	    		$('#draftPerson').val(changeNotice[0].draftPerson);
					    	    		/* $('#sign').val(changeNotice[0].sign);
					    	    		$('#approve').val(changeNotice[0].approve); */
					    			}
					    		});
								form.render();
							}
							,end: function () {
								var formDiv = document.getElementById('formDiv2');
								formDiv.style.display = '';
							}
						});
					})
				}
	    	}
	    })
		$.ajax({
	    	type:'post',
	    	url:'${pageContext.request.contextPath }/abnormalDisposalQuality/findAbnormalDisposalQualityByAdID.do',
	    	data:{"adID": obj.data.adID},
	    	success:function(data){
	    		$('#tab2').empty();
	    		var abnormalDisposalQuality = eval("("+data+")");
	    		if (abnormalDisposalQuality[0] == null) {
	    			$('#tab2').append('<div style="text-align: center;font-size: 25px;font-weight: 500;padding-top: 1em;">未处理</div>');
				} else {
					if (obj.data.isNormal == 1) {
						if (abnormalDisposalQuality[0].reserve1 == '0') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr></tbody></table>');
						} else if (abnormalDisposalQuality[0].reserve1 == '1') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr></tbody></table>');
						} else {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
				    		var reserve5 = '';
				    		if (abnormalDisposalQuality[0].reserve5 == '0') {
				    			reserve5 = '(已通过)';
							} else {
								reserve5 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr><tr height="100px;"><td style="width: 20%;">制造部处理意见</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion3+'</td></tr><tr><td colspan="2" style="text-align: right;">制造部负责人:'+
				    				abnormalDisposalQuality[0].makePerson+reserve5+'</td></tr></tbody></table>');
						}
					} else {
						if (abnormalDisposalQuality[0].reserve1 == '0') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr></tbody></table>');
						} else if (abnormalDisposalQuality[0].reserve1 == '1') {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr></tbody></table>');
						} else {
							var reserve3 = '';
				    		if (abnormalDisposalQuality[0].reserve3 == '0') {
				    			reserve3 = '(已通过)';
							} else {
								reserve3 = '(已驳回)';
							}
				    		var reserve4 = '';
				    		if (abnormalDisposalQuality[0].reserve4 == '0') {
				    			reserve4 = '(已通过)';
							} else {
								reserve4 = '(已驳回)';
							}
				    		var reserve5 = '';
				    		if (abnormalDisposalQuality[0].reserve5 == '0') {
				    			reserve5 = '(已通过)';
							} else {
								reserve5 = '(已驳回)';
							}
							$('#tab2').append('<h1 style="text-align: center;">品质处理结果</h1><table class="layui-table" style="width: 90%;padding-top: 1em;">'+
				    				'<tbody><tr height="100px;"><td style="width: 20%;">品质是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion+'</td></tr><tr><td colspan="2" style="text-align: right;">品质负责人:'+
				    				abnormalDisposalQuality[0].qualityPerson+reserve3+'</td></tr><tr height="100px;"><td style="width: 20%;">技术部是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion2+'</td></tr><tr><td colspan="2" style="text-align: right;">技术部负责人:'+
				    				abnormalDisposalQuality[0].techniquePerson+reserve4+'</td></tr><tr height="100px;"><td style="width: 20%;">制造部是否合格判定</td><td style="width: 80%;">'+
				    				abnormalDisposalQuality[0].opinion3+'</td></tr><tr><td colspan="2" style="text-align: right;">制造部负责人:'+
				    				abnormalDisposalQuality[0].makePerson+reserve5+'</td></tr></tbody></table>');
						}
					}
				}
	    	}
	    })
	    var tab = document.getElementById('tab');
		tab.style.display = '';
	});
	
	//头工具栏事件
	table.on('toolbar(test)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'add':
	    		var data = checkStatus.data;
	    		if (data.length == 0) {
	        		toastr.warning("请选择一条记录！");
	        		return false;
	        	}
	    		if (data.length > 1) {
	        		toastr.warning("只能选择一条记录！");
	        		return false;
	        	}
	    		layer.open({
					  type: 1 		//Page层类型
					  ,area: ['500px', '300px'] //宽  高
					  ,title: '新增'
					  ,shade: 0.6 	//遮罩透明度
					  ,shadeClose: true //点击遮罩关闭
					  ,maxmin: true //允许全屏最小化
					  ,anim: 1 		//0-6的动画形式，-1不开启
					  ,content: $('#formDiv3')
					  ,success: function () {
						  document.getElementById("addform").reset();
						  $('#adID').val(data[0].adID);
						  $('#reserve2').val(data[0].isNormal);
						  form.render();
					  }
					  ,end: function () {
						  var formDiv = document.getElementById('formDiv3');
						  formDiv.style.display = '';
					  }
					});
	      	break;
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
	table.on('toolbar(test1)', function(obj){
		var checkStatus = table.checkStatus(obj.config.id);
	    switch(obj.event){
	    	case 'add1':
	    		var data = checkStatus.data;
	    		if (data.length == 0) {
	        		toastr.warning("请选择一条记录！");
	        		return false;
	        	}
	    		if (data.length > 1) {
	        		toastr.warning("只能选择一条记录！");
	        		return false;
	        	}
	    		layer.open({
					  type: 1 		//Page层类型
					  ,area: ['500px', '300px'] //宽  高
					  ,title: '会签'
					  ,shade: 0.6 	//遮罩透明度
					  ,shadeClose: true //点击遮罩关闭
					  ,maxmin: true //允许全屏最小化
					  ,anim: 1 		//0-6的动画形式，-1不开启
					  ,content: $('#formDiv4')
					  ,success: function () {
						  document.getElementById("addform2").reset();
						  $('#noticeID').val(data[0].noticeID);
						  form.render();
					  }
					  ,end: function () {
						  var formDiv = document.getElementById('formDiv4');
						  formDiv.style.display = '';
					  }
					});
	      	break;
	      	case 'select':
	      		console.log(obj)
	      	break;
	    };
	});
	
	/**
     * 表单校验
     */
    form.verify({
    	//value：表单的值、item：表单的DOM对象
    	makePerson: function(value){
    		if(value == ''){
    			return '意见不能为空';
    		}
    	},
    	reserve4: function(value){
    		if(value == ''){
    			return '会签意见不能为空';
    		}
    	}
    });
    /**
     * 通用表单提交(AJAX方式)（新增）
     */
    form.on('submit(addform)', function (data) {
    	$("#subBtn1").attr("disabled",true);
    	$.ajax({
			url : '${pageContext.request.contextPath }/abnormalDisposalQuality/updateAbnormalDisposalQuality.do',
			data : $('#addform').serialize(),
			type : "post",
			dataType : "json",
			}).done(
				function(res) {
					if (res > 0) {
						toastr.success('新增成功！');
						setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},2000);
					}
				}
			).fail(
				function(res) {
					layer.close(1);
					toastr.error('新增失败！');
				}
			)
			return false;
    });
    form.on('submit(addform2)', function (data) {
    	$("#subBtn2").attr("disabled",true);
    	$.ajax({
			url : '${pageContext.request.contextPath }/changeNotice/saveChangeNotice.do',
			data : $('#addform2').serialize(),
			type : "post",
			dataType : "json",
			}).done(
				function(res) {
					if (res > 0) {
						toastr.success('新增成功！');
						setTimeout(function(){  //使用  setTimeout（）方法设定定时2000毫秒
							//关闭模态框
							// 父页面刷新
							window.location.reload();  
						},2000);
					}
				}
			).fail(
				function(res) {
					layer.close(1);
					toastr.error('新增失败！');
				}
			)
			return false;
    });
});

toastr.options.positionClass = 'toast-top-center'; //提示框的位置设置为中上
//处理记录
function attachDeviceEvent(reserve5,reserve2,qSignature,reserve3,tSignature,reserve4,maSignature,mOpinion,mSignature){
    layer.open({
        type: 1 					//Page层类型
        ,area: ['600px', '350px']   //宽  高
        ,title: '处理记录'
        ,shade: 0.6 				//遮罩透明度
        ,maxmin: true 			    //允许全屏最小化
        ,anim: 1 					//0-6的动画形式，-1不开启
        ,content: '<div id="lookupTable1"></div>'
        ,success: function(){
			if (reserve5 == '1') {
				$('#lookupTable1').append('<div style="margin: 5em 0 0 0;text-align: center;font-size: 20px;">未处理</div>')
			}
			if (reserve5 == '2') {
				$('#lookupTable1').append('<div class="layui-form" style="margin: 1em;"><table class="layui-table"><colgroup>'+
						'<col width="150"><col width="150"><col width="200"><col></colgroup><thead><tr>'+
						'<th>操作部门</th><th>操作人</th><th>意见</th></tr></thead><tbody><tr><td>品质监控部</td>'+
						'<td>'+qSignature+'</td><td>'+reserve2+'</td></tr></tbody></table></div>')
			}
			if (reserve5 == '3') {
				$('#lookupTable1').append('<div class="layui-form" style="margin: 1em;"><table class="layui-table"><colgroup>'+
						'<col width="150"><col width="150"><col width="200"><col></colgroup><thead><tr>'+
						'<th>操作部门</th><th>操作人</th><th>意见</th></tr></thead><tbody><tr><td>品质监控部</td>'+
						'<td>'+qSignature+'</td><td>'+reserve2+'</td></tr><tr><td>生产技术部</td><td>'+tSignature+
						'</td><td>'+reserve3+'</td></tr></tbody></table></div>')
			}
			if (reserve5 == '4') {
				$('#lookupTable1').append('<div class="layui-form" style="margin: 1em;"><table class="layui-table"><colgroup>'+
						'<col width="150"><col width="150"><col width="200"><col></colgroup><thead><tr>'+
						'<th>操作部门</th><th>操作人</th><th>意见</th></tr></thead><tbody><tr><td>品质监控部</td>'+
						'<td>'+qSignature+'</td><td>'+reserve2+'</td></tr><tr><td>生产技术部</td><td>'+tSignature+
						'</td><td>'+reserve3+'</td></tr><tr><td>生产制造部</td><td>'+maSignature+'</td><td>'+
						reserve3+'</td></tr></tbody></table></div>')
			}
			if (reserve5 == '5') {
				$('#lookupTable1').append('<div class="layui-form" style="margin: 1em;"><table class="layui-table"><colgroup>'+
						'<col width="150"><col width="150"><col width="200"><col></colgroup><thead><tr>'+
						'<th>操作部门</th><th>操作人</th><th>意见</th></tr></thead><tbody><tr><td>品质监控部</td>'+
						'<td>'+qSignature+'</td><td>'+reserve2+'</td></tr><tr><td>生产技术部</td><td>'+tSignature+
						'</td><td>'+reserve3+'</td></tr><tr><td>生产制造部</td><td>'+maSignature+'</td><td>'+
						reserve3+'</td></tr><tr><td>基地经理</td><td>'+mSignature+'</td><td>'+mOpinion+'</td></tr></tbody></table></div>')
			}
        }
    });
}
</script>

</body>
</html>